package com.ruoyi.project.modules.processBranchConditionDetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.modules.processBranchConditionDetail.domain.ProcessBranchConditionDetail;
import com.ruoyi.project.modules.processBranchConditionDetail.service.IProcessBranchConditionDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分支条件明细Controller
 * 
 * @author smallrain
 * @date 2022-04-02
 */
@Controller
@RequestMapping("/processBranchConditionDetail/processBranchConditionDetail")
public class ProcessBranchConditionDetailController extends BaseController
{
    private String prefix = "processBranchConditionDetail/processBranchConditionDetail";

    @Autowired
    private IProcessBranchConditionDetailService processBranchConditionDetailService;

    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:view")
    @GetMapping()
    public String processBranchConditionDetail()
    {
        return prefix + "/processBranchConditionDetail";
    }

    /**
     * 查询分支条件明细列表
     */
    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProcessBranchConditionDetail processBranchConditionDetail)
    {
        startPage();
        List<ProcessBranchConditionDetail> list = processBranchConditionDetailService.selectProcessBranchConditionDetailList(processBranchConditionDetail);
        return getDataTable(list);
    }

    /**
     * 导出分支条件明细列表
     */
    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:export")
    @Log(title = "分支条件明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProcessBranchConditionDetail processBranchConditionDetail)
    {
        List<ProcessBranchConditionDetail> list = processBranchConditionDetailService.selectProcessBranchConditionDetailList(processBranchConditionDetail);
        ExcelUtil<ProcessBranchConditionDetail> util = new ExcelUtil<ProcessBranchConditionDetail>(ProcessBranchConditionDetail.class);
        return util.exportExcel(list, "分支条件明细数据");
    }

    /**
     * 新增分支条件明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存分支条件明细
     */
    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:add")
    @Log(title = "分支条件明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProcessBranchConditionDetail processBranchConditionDetail)
    {
        return toAjax(processBranchConditionDetailService.insertProcessBranchConditionDetail(processBranchConditionDetail));
    }

    /**
     * 修改分支条件明细
     */
    @GetMapping("/edit/{branchConditionDetailId}")
    public String edit(@PathVariable("branchConditionDetailId") Long branchConditionDetailId, ModelMap mmap)
    {
        ProcessBranchConditionDetail processBranchConditionDetail = processBranchConditionDetailService.selectProcessBranchConditionDetailByBranchConditionDetailId(branchConditionDetailId);
        mmap.put("processBranchConditionDetail", processBranchConditionDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存分支条件明细
     */
    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:edit")
    @Log(title = "分支条件明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProcessBranchConditionDetail processBranchConditionDetail)
    {
        return toAjax(processBranchConditionDetailService.updateProcessBranchConditionDetail(processBranchConditionDetail));
    }

    /**
     * 删除分支条件明细
     */
    @RequiresPermissions("processBranchConditionDetail:processBranchConditionDetail:remove")
    @Log(title = "分支条件明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(processBranchConditionDetailService.deleteProcessBranchConditionDetailByBranchConditionDetailIds(ids));
    }
}
